#include "index_buffer.hpp"
#include "renderer.hpp"

IndexBuffer::IndexBuffer( const unsigned int * data, unsigned int count )
    : _count( count )
{
    ASSERT( sizeof( unsigned int ) == sizeof( GLuint ) );

    GLCall( glGenBuffers( 1, &_rendererID ) );
    GLCall( glBindBuffer( GL_ELEMENT_ARRAY_BUFFER, _rendererID ) );
    glBufferData( GL_ELEMENT_ARRAY_BUFFER, count * sizeof( unsigned int ), data, GL_STATIC_DRAW );

}

IndexBuffer::~IndexBuffer()
{
}


void IndexBuffer::bind() const
{
    GLCall( glBindBuffer( GL_ARRAY_BUFFER, _rendererID ) );
}

void IndexBuffer::unbind() const
{
    GLCall( glBindBuffer( GL_ARRAY_BUFFER, 0 ) );
}
